#define DEBUG
#include <cstdio>
#include <algorithm>

using namespace std;

const int maxn=200000, maxr=1000000;
const long long inf=0x7ffffffffffffff;

class Monster {
public:
  long long v;
  int id;

  static bool cmp(Monster a, Monster b) {
    return a.v<b.v;
  }
};

class Graph {
public:
  int m, ind[maxn+1], link[maxr+1], to[maxr+1], in[maxn+1];
  long long s[maxn+1], k[maxn+1], v[maxn+1];

  void addSide(int u, int v) {
    m++;
    to[m] = v;
    link[m] = ind[u];
    ind[u] = m;
    in[v]++;
  }

  void update(int &h, int &t, int que[]) {
    for (; h<t; ) {
      int x=que[++h], z;
      long long y=min(k[x], s[x]+v[x]);
      for (int i=ind[x]; i; i=link[i]) {
	in[z=to[i]]--;
	if (in[z]>=0) {
	  v[z]+=y;
	}
	if (!in[z]) {
	  que[++t] = z;
	}
      }
    }
  }
};

int main() {
  freopen("knight.in", "r", stdin);
  freopen("knight.out", "w", stdout);

  static Graph g;
  static Monster monsters[maxn+1];
  int n;
  scanf("%d", &n);
  for (int i=1; i<=n; i++) {
    int r;
    scanf("%lld %lld %d", g.s+i, g.k+i, &r);
    monsters[i].id = i, monsters[i].v = g.k[i];
    for (int j=1; j<=r; j++) {
      int t;
      scanf("%d", &t);
      g.addSide(t, i);
    }
  }

  sort(monsters+1, monsters+n+1, Monster::cmp);

  static int que[maxn+1];
  int h=0, t=0;
  for (int i=1; i<=n; i++) {
    if (!g.in[i]) {
      que[++t] = i;
    }
  }
  g.update(h, t, que);
  for (int i=1; i<=n; i++) {
    int x;
    if (g.in[x=monsters[i].id]>0) {
      g.in[x] = 0, g.v[x] = inf-g.s[x];
      que[++t] = x;
      g.update(h, t, que);
    }
  }

  printf("%lld", min(g.k[1], g.s[1]+g.v[1]));

  fclose(stdin);
  fclose(stdout);
  return 0;
}
